package priv.pront.code.mati.national.practice;

import java.util.Scanner;

/**
 * @Author: Pronting
 * @Description:
 * @DateTime: 2023/12/1 13:02
 **/
public class P1098_字符串的展开 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int p1 = scanner.nextInt();
        int p2 = scanner.nextInt();
        int p3 = scanner.nextInt();
        scanner.nextLine(); // Consume the newline
        String input = scanner.nextLine();
        StringBuilder output = new StringBuilder();

        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (c == '-' && i > 0 && i < input.length() - 1) {
                char start = input.charAt(i - 1);
                char end = input.charAt(i + 1);
                if (start + 1 == end) { // Case 5
                    continue;
                }
                if (start >= end || !(Character.isDigit(start) && Character.isDigit(end)) &&
                        !(Character.isLetter(start) && Character.isLetter(end))) {
                    output.append(c);
                    continue;
                }

                StringBuilder expansion = new StringBuilder();
                for (char j = (char) (start + 1); j < end; j++) {
                    for (int k = 0; k < p2; k++) { // p2: repeat count
                        char ch = (p1 == 3) ? '*' : j;
                        if (p1 == 2 && Character.isLetter(j)) {
                            ch = Character.toUpperCase(ch);
                        }
                        expansion.append(ch);
                    }
                }
                if(p3 == 2){
                    output.append(expansion.reverse().toString());
                }else{
                    output.append(expansion.toString());
                }
            } else {
                output.append(c);
            }
        }

        System.out.println(output.toString());
    }
}
